package com.syt.cellphone.information.ui

import android.os.Bundle
import android.util.Log
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.NavUtils
import com.bumptech.glide.Glide
import com.syt.cellphone.information.R
import kotlinx.android.synthetic.main.activity_test1.*

/**
 *  @author: syt
 *  创建时间: 2020/9/4 17:23
 *  @功能
 *  @version v1.0
 */
class TestActivity : AppCompatActivity() {

    val TAG = this.javaClass.simpleName

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_test1)
        Glide.with(this)
            .load("http://img.netbian.com/file/2020/0905/small9ef1b3215a1d2e2aabbb899e49dc1a361599317162.jpg")
            .into(iv_test)
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
            nestedScrollView_test.setOnScrollChangeListener {
                    v,
                    scrollX,
                    scrollY,
                    oldScrollX,
                    oldScrollY ->
                // 滑动时，直接给标题上名称
                toolbar.title = "标题"
            }
        }
        actionBar?.setDisplayHomeAsUpEnabled(true)
        Log.d(TAG, "onCreate: ")
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        if (item.itemId == android.R.id.home) {
            NavUtils.navigateUpFromSameTask(this)
            return true
        }
        return super.onOptionsItemSelected(item)
    }

    override fun onStart() {
        super.onStart()
        Log.d(TAG, "onStart: ")
    }

    override fun onResume() {
        super.onResume()
        Log.d(TAG, "onResume: ")
    }

    override fun onPause() {
        super.onPause()
        Log.d(TAG, "onPause: ")
    }

    override fun onStop() {
        super.onStop()
        Log.d(TAG, "onStop: ")
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.d(TAG, "onDestroy: ")
    }
}